﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Newtonsoft.Json;
using VietPay.KooBoo.Business;
using VietPay.KooBoo.Data;
using VietPay.KooBoo.Data.EntityModels;
using VietPay.KooBoo.Business.Models;

namespace MyTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //FileInfo fInfo = new FileInfo(@"c:\Kooboo CMS.chm");
            //long size = fInfo.Length;

            List<jsonSave> lstJson = new List<jsonSave>();
            jsonSave js = new jsonSave();
            js.DistributorID = 1;
            js.BatchDetailID= 123;
            lstJson.Add(js);

            string json = JsonConvert.SerializeObject(lstJson);

            List<jsonSave> deserializedProduct = JsonConvert.DeserializeObject<List<jsonSave>>(json);
        }

        private void batchCreate_Click(object sender, EventArgs e)
        {
            BatchService btService = new BatchService();

            Batch batch = new Batch();
            batch.BathCode = "B" + DateTime.Now.ToString("yyMMddhhssff");
            batch.CreatedDate= DateTime.Now;
            batch.UserCreate= "hungdv";
            batch.CategoryID = 1;
            batch.DistributorID = 2;
            batch.ParentDistributorID = 1;


            List<BatchDetail> lstBatchDetail = new List<BatchDetail>();
            BatchDetail bDetail = new BatchDetail();
            bDetail.ProductID = 4;
            bDetail.Quantity= 20;
            bDetail.Price= 46000;

            lstBatchDetail.Add(bDetail);

            btService.BatchCreate(batch, lstBatchDetail);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //VMS2_TestEntities test = new VMS2_TestEntities();

            //Category category = new Category();
            //category.CategoryCode = "Test0001";
            //category.CategoryName = "Mã thẻ";
            //test.Categories.AddObject(category);
            //test.SaveChanges();
        }

        private void GoodsList_Click(object sender, EventArgs e)
        {
            GoodService target = new GoodService(); // TODO: Initialize to an appropriate value
            Nullable<int> distributorID = new Nullable<int>(); // TODO: Initialize to an appropriate value
            Nullable<int> productID = new Nullable<int>(); // TODO: Initialize to an appropriate value
            distributorID = 2;
            productID = 1;
            int PageSize = 100; // TODO: Initialize to an appropriate value
            int CurrentPage = 1; // TODO: Initialize to an appropriate value
            GoodsListViewModel expected = null; // TODO: Initialize to an appropriate value
            GoodsListViewModel actual;
            actual = target.GetGoodList(distributorID, productID, PageSize, CurrentPage);
            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

    }

    public class jsonSave
    {
        public int DistributorID { set; get; }
        public int BatchDetailID { set; get; }

    }
}
